package br.com.view;

import br.com.dao.ConectaBanco;
import br.com.dao.ModeloTabela;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;

/**
 *
 * @author Cícero
 */
public class Frm_setor extends javax.swing.JFrame {

    ConectaBanco conexao = new ConectaBanco();

    /**
     * Creates new form frm_setor
     */
    public Frm_setor() {
        initComponents();
        conexao.conexao();
        geraTabela("select * from setor order by idTBSetor");
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("bdsysepi?zeroDateTimeBehavior=convertToNullPU").createEntityManager();
        tbsetorQuery = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT t FROM Tbsetor t");
        tbsetorList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : tbsetorQuery.getResultList();
        tbsetorQuery1 = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT t FROM Tbsetor t");
        tbsetorList1 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : tbsetorQuery1.getResultList();
        entityManager0 = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("bancosysepi?zeroDateTimeBehavior=convertToNullPU").createEntityManager();
        setorQuery = java.beans.Beans.isDesignTime() ? null : entityManager0.createQuery("SELECT s FROM Setor s");
        setorList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : setorQuery.getResultList();
        lblNome = new javax.swing.JLabel();
        textNomeSetor = new javax.swing.JTextField();
        lblDescricao = new javax.swing.JLabel();
        textDescricao = new javax.swing.JTextField();
        lblResp = new javax.swing.JLabel();
        textResp = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        tableSetor = new javax.swing.JTable();
        lblRiscos = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        textAreaR = new javax.swing.JTextArea();
        lblObservacoes = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        textAreaO = new javax.swing.JTextArea();
        btnNovo = new javax.swing.JButton();
        btnAlterar = new javax.swing.JButton();
        btnExcluir = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        btnSalvar = new javax.swing.JButton();
        lblfrmCadastroSetor = new javax.swing.JLabel();
        lblCodigo = new javax.swing.JLabel();
        textCodigoSetor = new javax.swing.JTextField();
        btnPrimeiro = new javax.swing.JButton();
        btnAnterior = new javax.swing.JButton();
        btnProximo = new javax.swing.JButton();
        btnUltimo = new javax.swing.JButton();
        lblEmail = new javax.swing.JLabel();
        textEmail = new javax.swing.JTextField();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jSeparator3 = new javax.swing.JSeparator();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Cadastro de Setor");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lblNome.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblNome.setText("Nome");
        getContentPane().add(lblNome, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 100, -1, -1));

        textNomeSetor.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        textNomeSetor.setEnabled(false);
        getContentPane().add(textNomeSetor, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 100, 300, -1));

        lblDescricao.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblDescricao.setText("Descrição");
        getContentPane().add(lblDescricao, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 130, -1, -1));

        textDescricao.setEnabled(false);
        getContentPane().add(textDescricao, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 130, 290, -1));

        lblResp.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblResp.setText("Responsavel");
        getContentPane().add(lblResp, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 160, -1, -1));

        textResp.setEnabled(false);
        getContentPane().add(textResp, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 160, 270, -1));

        tableSetor.setAutoCreateRowSorter(true);
        tableSetor.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(tableSetor);

        getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 100, 480, 310));

        lblRiscos.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblRiscos.setText("Riscos");
        getContentPane().add(lblRiscos, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 220, -1, -1));

        textAreaR.setColumns(20);
        textAreaR.setRows(5);
        textAreaR.setEnabled(false);
        jScrollPane2.setViewportView(textAreaR);

        getContentPane().add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 240, 337, 70));

        lblObservacoes.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblObservacoes.setText("Observações");
        getContentPane().add(lblObservacoes, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 320, -1, -1));

        textAreaO.setColumns(20);
        textAreaO.setRows(5);
        textAreaO.setEnabled(false);
        jScrollPane3.setViewportView(textAreaO);

        getContentPane().add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 340, 337, 70));

        btnNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones sysepi/favicon(42).png"))); // NOI18N
        btnNovo.setText("Novo");
        btnNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovoActionPerformed(evt);
            }
        });
        getContentPane().add(btnNovo, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 450, -1, -1));

        btnAlterar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones sysepi/favicon (7).png"))); // NOI18N
        btnAlterar.setText("Alterar");
        btnAlterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAlterarActionPerformed(evt);
            }
        });
        getContentPane().add(btnAlterar, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 450, -1, -1));

        btnExcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones sysepi/favicon (3).png"))); // NOI18N
        btnExcluir.setText("Excluir");
        btnExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExcluirActionPerformed(evt);
            }
        });
        getContentPane().add(btnExcluir, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 450, -1, -1));

        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones sysepi/favicon (4).png"))); // NOI18N
        btnCancelar.setText("Cancelar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });
        getContentPane().add(btnCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 450, -1, -1));

        btnSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones sysepi/favicon (29).png"))); // NOI18N
        btnSalvar.setText("Salvar");
        btnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalvarActionPerformed(evt);
            }
        });
        getContentPane().add(btnSalvar, new org.netbeans.lib.awtextra.AbsoluteConstraints(760, 450, -1, -1));

        lblfrmCadastroSetor.setFont(new java.awt.Font("Tahoma", 1, 22)); // NOI18N
        lblfrmCadastroSetor.setText("Cadastro de Setor");
        lblfrmCadastroSetor.setVerifyInputWhenFocusTarget(false);
        getContentPane().add(lblfrmCadastroSetor, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 10, 220, -1));

        lblCodigo.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblCodigo.setText("Código");
        getContentPane().add(lblCodigo, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, -1, -1));

        textCodigoSetor.setEnabled(false);

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, tableSetor, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.idTBSetor}"), textCodigoSetor, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        getContentPane().add(textCodigoSetor, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 70, 57, -1));

        btnPrimeiro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones sysepi/favicon (43).png"))); // NOI18N
        btnPrimeiro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPrimeiroActionPerformed(evt);
            }
        });
        getContentPane().add(btnPrimeiro, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 450, -1, -1));

        btnAnterior.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones sysepi/favicon (2).png"))); // NOI18N
        btnAnterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAnteriorActionPerformed(evt);
            }
        });
        getContentPane().add(btnAnterior, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 450, -1, -1));

        btnProximo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones sysepi/favicon (24).png"))); // NOI18N
        btnProximo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnProximoActionPerformed(evt);
            }
        });
        getContentPane().add(btnProximo, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 450, -1, -1));

        btnUltimo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones sysepi/favicon (16).png"))); // NOI18N
        btnUltimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUltimoActionPerformed(evt);
            }
        });
        getContentPane().add(btnUltimo, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 450, -1, -1));

        lblEmail.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblEmail.setText("Email");
        getContentPane().add(lblEmail, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 190, -1, -1));

        textEmail.setEnabled(false);
        getContentPane().add(textEmail, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 190, 310, -1));

        jSeparator1.setForeground(new java.awt.Color(0, 102, 102));
        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        getContentPane().add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 30, 550, 0));

        jSeparator2.setForeground(new java.awt.Color(0, 102, 102));
        getContentPane().add(jSeparator2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, 860, -1));

        jSeparator3.setForeground(new java.awt.Color(0, 102, 102));
        getContentPane().add(jSeparator3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 430, 860, -1));

        bindingGroup.bind();

        setSize(new java.awt.Dimension(898, 542));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void btnNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoActionPerformed
        NovoSetor();
    }//GEN-LAST:event_btnNovoActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        Cancelar();
        conexao.desconecta();
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
        conexao.conexao();
        String sqlInserir = ("INSERT INTO setor (nome_setor, descricao_setor, responsavel_setor, risco_setor, observacoes_setor, email_setor) values (?,?,?,?,?,?)");
        try {
            PreparedStatement pst = conexao.con.prepareStatement(sqlInserir);
            pst.setString(1, textNomeSetor.getText());
            pst.setString(2, textDescricao.getText());
            pst.setString(3, textResp.getText());
            pst.setString(4, textAreaR.getText());
            pst.setString(5, textAreaO.getText());
            pst.setString(6, textEmail.getText());
            pst.execute();
            pst.close();
            JOptionPane.showMessageDialog(null, "Salvo com Sucesso!");
            geraTabela("select * from setor order by idTBSetor");
            conexao.desconecta();
        } catch (SQLException erro) {
            JOptionPane.showMessageDialog(null, "Erro ao inserir o setor" + erro);
            conexao.desconecta();
        }
        conexao.desconecta();
        Cancelar();
    }//GEN-LAST:event_btnSalvarActionPerformed

    private void btnExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExcluirActionPerformed
        conexao.conexao();
        String sqlExcluir = (" delete from setor where idTBSetor ='" + this.textCodigoSetor.getText() + "'");
        try {
            conexao.executaSQL(sqlExcluir);
            conexao.pst.close();
            JOptionPane.showMessageDialog(null, "Excluido com Sucesso!");
            geraTabela("select * from setor order by idTBSetor");
            conexao.desconecta();
        } catch (SQLException erro) {
            JOptionPane.showMessageDialog(null, erro);
            conexao.desconecta();
        }
        //conexao.desconecta();
    }//GEN-LAST:event_btnExcluirActionPerformed

    private void btnAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAlterarActionPerformed
        conexao.conexao();
        String sqlAlterar = (" update setor set nome_setor = ?, descricao_setor = ?, responsavel_setor = ?, email_setor = ?, risco_setor = ?, observacoes_setor = ?  where idTBSetor=? ");
        try {
            PreparedStatement pst = conexao.con.prepareStatement(sqlAlterar);
            pst.setString(1, textNomeSetor.getText());
            pst.setString(2, textDescricao.getText());
            pst.setString(3, textResp.getText());
            pst.setString(4, textEmail.getText());
            pst.setString(5, textAreaR.getText());
            pst.setString(6, textAreaO.getText());
            pst.setInt(7, Integer.parseInt(textCodigoSetor.getText()));
            pst.executeUpdate();
            pst.close();
            JOptionPane.showMessageDialog(null, "Alterado com Sucesso!");
            geraTabela("select * from setor order by idTBSetor");
            conexao.desconecta();
        } catch (SQLException erro) {
            JOptionPane.showMessageDialog(null, "Erro ao Alterar" + erro);
            conexao.desconecta();
        }
        //conexao.desconecta();
    }//GEN-LAST:event_btnAlterarActionPerformed

    private void btnPrimeiroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrimeiroActionPerformed
        NovoSetor();
        conexao.conexao();
        try {
            conexao.executaSQL("select * from setor");
            conexao.rs.first();
            textCodigoSetor.setText(String.valueOf(conexao.rs.getInt("idTBSetor")));
            textNomeSetor.setText(conexao.rs.getString("nome_setor"));
            textDescricao.setText(conexao.rs.getString("descricao_setor"));
            textResp.setText(conexao.rs.getString("responsavel_setor"));
            textEmail.setText(conexao.rs.getString("email_setor"));
            textAreaR.setText(conexao.rs.getString("risco_setor"));
            textAreaO.setText(conexao.rs.getString("observacoes_setor"));
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, ex);
            conexao.desconecta();
        }
        //conexao.desconecta();
    }//GEN-LAST:event_btnPrimeiroActionPerformed

    private void btnUltimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUltimoActionPerformed
        NovoSetor();
        conexao.conexao();
        try {
            conexao.executaSQL("select * from setor");
            conexao.rs.last();
            textNomeSetor.setText(conexao.rs.getString("nome_setor"));
            textDescricao.setText(conexao.rs.getString("descricao_setor"));
            textResp.setText(conexao.rs.getString("responsavel_setor"));
            textEmail.setText(conexao.rs.getString("email_setor"));
            textAreaR.setText(conexao.rs.getString("risco_setor"));
            textAreaO.setText(conexao.rs.getString("observacoes_setor"));
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "erro ultimo" + ex);
            conexao.desconecta();
        }
        conexao.desconecta();
    }//GEN-LAST:event_btnUltimoActionPerformed

    private void btnAnteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAnteriorActionPerformed
        conexao.conexao();
        try {
            conexao.rs.previous();
            textNomeSetor.setText(conexao.rs.getString("nome_setor"));
            textDescricao.setText(conexao.rs.getString("descricao_setor"));
            textResp.setText(conexao.rs.getString("responsavel_setor"));
            textEmail.setText(conexao.rs.getString("email_setor"));
            textAreaR.setText(conexao.rs.getString("risco_setor"));
            textAreaO.setText(conexao.rs.getString("observacoes_setor"));
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Erro anterior" + ex);
            conexao.desconecta();
        }
        conexao.desconecta();
    }//GEN-LAST:event_btnAnteriorActionPerformed

    private void btnProximoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProximoActionPerformed
        conexao.conexao();
        try {
            conexao.rs.next();
            textNomeSetor.setText(conexao.rs.getString("nome_setor"));
            textDescricao.setText(conexao.rs.getString("descricao_setor"));
            textResp.setText(conexao.rs.getString("responsavel_setor"));
            textEmail.setText(conexao.rs.getString("email_setor"));
            textAreaR.setText(conexao.rs.getString("risco_setor"));
            textAreaO.setText(conexao.rs.getString("observacoes_setor"));
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Erro proximo" + ex);
            conexao.desconecta();
        }
        conexao.desconecta();
    }//GEN-LAST:event_btnProximoActionPerformed

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
//        try {
//            this.conexao.con.close();
//        } catch (SQLException ex) {
//            JOptionPane.showMessageDialog(null, "Erro ao fecha o formulario"+ex);
//        }
    }//GEN-LAST:event_formWindowClosed

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
//        conexao.conexao();
    }//GEN-LAST:event_formWindowActivated

    public void NovoSetor() {

        textNomeSetor.setEnabled(true);
        textDescricao.setEnabled(true);
        textResp.setEnabled(true);
        textEmail.setEnabled(true);
        textAreaO.setEnabled(true);
        textAreaR.setEnabled(true);
        textNomeSetor.requestFocus();

    }

    public void Cancelar() {

        textNomeSetor.setText("");
        textDescricao.setText("");
        textResp.setText("");
        textEmail.setText("");
        textAreaO.setText("");
        textAreaR.setText("");
        btnNovo.requestFocus();
        textNomeSetor.setEnabled(false);
        textDescricao.setEnabled(false);
        textResp.setEnabled(false);
        textEmail.setEnabled(false);
        textAreaO.setEnabled(false);
        textAreaR.setEnabled(false);
    }

    @SuppressWarnings("empty-statement")

    public void geraTabela(String SQL) {
        ArrayList dados = new ArrayList();
        String[] Colunas = new String[]{"Codigo", "Nome", "Descrição", "Responsavel", "E-mail"};
        conexao.executaSQL(SQL);
        try {
            conexao.rs.first();
            do {
                dados.add((new Object[]{conexao.rs.getInt("idTBSetor"), conexao.rs.getString("nome_setor"), conexao.rs.getString("descricao_setor"), conexao.rs.getString("responsavel_setor"), conexao.rs.getString("email_setor")}));
            } while (conexao.rs.next());
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Erro ao preencher o arrayList" + ex);
            //conexao.desconecta();
        }
        ModeloTabela modeloTabela = new ModeloTabela(dados, Colunas);

        tableSetor.setModel(modeloTabela);
        tableSetor.getColumnModel().getColumn(0).setPreferredWidth(180);
        tableSetor.getColumnModel().getColumn(0).setResizable(false);
        tableSetor.getColumnModel().getColumn(1).setPreferredWidth(280);
        tableSetor.getColumnModel().getColumn(1).setResizable(false);
        tableSetor.getColumnModel().getColumn(2).setPreferredWidth(180);
        tableSetor.getColumnModel().getColumn(2).setResizable(false);
        tableSetor.getColumnModel().getColumn(3).setPreferredWidth(180);
        tableSetor.getColumnModel().getColumn(3).setResizable(false);
        tableSetor.getColumnModel().getColumn(4).setPreferredWidth(180);
        tableSetor.getColumnModel().getColumn(4).setResizable(false);

        tableSetor.getTableHeader().setReorderingAllowed(false);
        tableSetor.setAutoResizeMode(tableSetor.AUTO_RESIZE_OFF);
        tableSetor.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    }
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Frm_Acesso.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Frm_Acesso.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Frm_Acesso.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Frm_Acesso.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Frm_setor().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAlterar;
    private javax.swing.JButton btnAnterior;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnExcluir;
    private javax.swing.JButton btnNovo;
    private javax.swing.JButton btnPrimeiro;
    private javax.swing.JButton btnProximo;
    private javax.swing.JButton btnSalvar;
    private javax.swing.JButton btnUltimo;
    private javax.persistence.EntityManager entityManager;
    private javax.persistence.EntityManager entityManager0;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JLabel lblCodigo;
    private javax.swing.JLabel lblDescricao;
    private javax.swing.JLabel lblEmail;
    private javax.swing.JLabel lblNome;
    private javax.swing.JLabel lblObservacoes;
    private javax.swing.JLabel lblResp;
    private javax.swing.JLabel lblRiscos;
    private javax.swing.JLabel lblfrmCadastroSetor;
    private java.util.List<br.com.model.Setor> setorList;
    private javax.persistence.Query setorQuery;
    private javax.swing.JTable tableSetor;
    private java.util.List<br.com.model.Tbsetor> tbsetorList;
    private java.util.List<br.com.model.Tbsetor> tbsetorList1;
    private javax.persistence.Query tbsetorQuery;
    private javax.persistence.Query tbsetorQuery1;
    private javax.swing.JTextArea textAreaO;
    private javax.swing.JTextArea textAreaR;
    private javax.swing.JTextField textCodigoSetor;
    private javax.swing.JTextField textDescricao;
    private javax.swing.JTextField textEmail;
    private javax.swing.JTextField textNomeSetor;
    private javax.swing.JTextField textResp;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

}
